package com.ku.pksu.bornegaarden.util;

import android.content.Context;
import android.os.AsyncTask;
import android.util.Log;
import java.net.ConnectException;

import com.ku.pksu.bornegaarden.R;

public class DownloadAsync<T> extends AsyncTask<T, Void, Void> {

	private FetchListener fl;

	@Override
	protected Void doInBackground(T... params) {
		fl = (FetchListener)params[1];

		HTTPFetcher fetch = new HTTPFetcher((Context)params[0]);
		String[] array = ((Context)params[0]).getResources().getStringArray(R.array.InfoItemLinks);

		for(String s : array){
			Log.e("Fetch", "Fetching "+s);
			fetch.fetch(s.substring(0, s.length()-4));
		}
		return null;
	}

	@Override
	protected void onPostExecute(Void result) {
		super.onPostExecute(result);
		fl.downloadComplete();
	}
}